}
}
+.unlock-dialog-notification-icon {
+ icon-size: $large_icon_size;
+}
+
.unlock-dialog-notification-label {
padding-left: $base_padding * 2;
padding-right: 0;
const SHOW_WEEKDATE_KEY = 'show-weekdate';
-const MESSAGE_ICON_SIZE = -1; // pick up from CSS
-
const NC_ = (context, str) => `${context}\u0004${str}`;
function sameYear(dateA, dateB) {
if (this.notification.gicon) {
return new St.Icon({
gicon: this.notification.gicon,
- icon_size: MESSAGE_ICON_SIZE,
});
} else {
return null;
this.showNotification(this._notification);
}
- getIcon() {
+ get icon() {
return this.mount.get_icon();
}
this._notification.appendAliasChange(oldAlias, newAlias);
}
- getIcon() {
+ get icon() {
let file = this._contact.get_avatar_file();
if (file)
return new Gio.FileIcon({file});
}
_updateAvatarIcon() {
- this.iconUpdated();
+ this.notify('icon');
if (this._notification) {
this._notification.update(
this._notification.title,
this._notification.bannerBodyText,
- {gicon: this.getIcon()});
+ {gicon: this.icon});
}
}
super._init(this._app.get_name());
}
- getIcon() {
+ get icon() {
return this._app.app_info.get_icon();
}
}
});
-export const SourceActor = GObject.registerClass(
-class SourceActor extends St.Widget {
- _init(source, size) {
- super._init();
-
- this._source = source;
- this._size = size;
-
- this.connect('destroy',
- () => (this._actorDestroyed = true));
- this._actorDestroyed = false;
-
- let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
- this._iconBin = new St.Bin({
- x_expand: true,
- height: size * scaleFactor,
- width: size * scaleFactor,
- });
-
- this.add_child(this._iconBin);
-
- this._source.connectObject('icon-updated',
- this._updateIcon.bind(this), this);
- this._updateIcon();
- }
-
- setIcon(icon) {
- this._iconBin.child = icon;
- this._iconSet = true;
- }
-
- _updateIcon() {
- if (this._actorDestroyed)
- return;
-
- if (!this._iconSet)
- this._iconBin.child = this._source.createIcon(this._size);
- }
-});
-
export const Source = GObject.registerClass({
Properties: {
'count': GObject.ParamSpec.int(
'title', 'title', 'title',
GObject.ParamFlags.READWRITE,
null),
+ 'icon': GObject.ParamSpec.object(
+ 'icon', 'icon', 'icon',
+ GObject.ParamFlags.READWRITE,
+ Gio.Icon),
+ 'icon-name': GObject.ParamSpec.string(
+ 'icon-name', 'icon-name', 'icon-name',
+ GObject.ParamFlags.READWRITE,
+ null),
},
Signals: {
'destroy': {param_types: [GObject.TYPE_UINT]},
- 'icon-updated': {},
'notification-added': {param_types: [Notification.$gtype]},
'notification-show': {param_types: [Notification.$gtype]},
},
_init(title, iconName) {
super._init({title});
- this.iconName = iconName;
+ this.icon = new Gio.ThemedIcon({name: iconName});
this.notifications = [];
return new NotificationBanner(notification);
}
- // Called to create a new icon actor.
- // Provides a sane default implementation, override if you need
- // something more fancy.
- createIcon(size) {
- return new St.Icon({
- gicon: this.getIcon(),
- icon_size: size,
- });
+ get iconName() {
+ if (this.gicon instanceof Gio.ThemedIcon)
+ return this.gicon.iconName;
+ else
+ return null;
}
- getIcon() {
- return new Gio.ThemedIcon({name: this.iconName});
+ set iconName(iconName) {
+ this.icon = new Gio.ThemedIcon({name: iconName});
}
_onNotificationDestroy(notification) {
this.run_dispose();
}
- iconUpdated() {
- this.emit('icon-updated');
- }
-
// To be overridden by subclasses
open() {
}
import GLib from 'gi://GLib';
import GObject from 'gi://GObject';
import Shell from 'gi://Shell';
-import St from 'gi://St';
import * as Config from '../misc/config.js';
import * as Main from './main.js';
this.destroy();
}
- processNotification(notification, gicon) {
- if (gicon)
- this._gicon = gicon;
- this.iconUpdated();
+ processNotification(notification, appIcon) {
+ if (!this.app && appIcon) {
+ this._appIcon = appIcon;
+ this.notify('icon');
+ }
let tracker = Shell.WindowTracker.get_default();
if (notification.resident && this.app && tracker.focus_app === this.app)
super.destroy();
}
- createIcon(size) {
- if (this.app) {
- return this.app.create_icon_texture(size);
- } else if (this._gicon) {
- return new St.Icon({
- gicon: this._gicon,
- icon_size: size,
- });
- } else {
+ get icon() {
+ if (this.app)
+ return this.app.get_icon();
+ else if (this._appIcon)
+ return this._appIcon;
+ else
return null;
- }
}
});
this._notificationPending = false;
}
- createIcon(size) {
- return this._app.create_icon_texture(size);
+ get icon() {
+ return this._app.get_icon();
}
_createPolicy() {
const BLUR_BRIGHTNESS = 0.65;
const BLUR_RADIUS = 90;
-const SUMMARY_ICON_SIZE = 32;
-
const NotificationsBox = GObject.registerClass({
Signals: {'wake-up-screen': {}},
}, class NotificationsBox extends St.BoxLayout {
}
_makeNotificationSource(source, box) {
- let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
- box.add_child(sourceActor);
+ let iconActor = new St.Icon({
+ style_class: 'unlock-dialog-notification-icon',
+ fallback_icon_name: 'application-x-executable',
+ });
+ source.bind_property('icon', iconActor, 'gicon', GObject.BindingFlags.SYNC_CREATE);
+ box.add_child(iconActor);
let textBox = new St.BoxLayout({
x_expand: true,
}
_makeNotificationDetailedSource(source, box) {
- let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
- let sourceBin = new St.Bin({child: sourceActor});
- box.add_child(sourceBin);
+ let iconActor = new St.Icon({
+ style_class: 'unlock-dialog-notification-icon',
+ fallback_icon_name: 'application-x-executable',
+ });
+ source.bind_property('icon', iconActor, 'gicon', GObject.BindingFlags.SYNC_CREATE);
+ box.add_child(iconActor);
let textBox = new St.BoxLayout({vertical: true});
box.add_child(textBox);
}
}
- createIcon(size) {
- return this._app.create_icon_texture(size);
+ get icon() {
+ return this._app.get_icon();
}
destroy(params) {